<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> REST TEST </title>
</head>
<body>

<p><u><b>Response</b></u></p>

<?php

	require_once('./lib.php');
	$response = sendPOST($config['base_url'].'/asessions/begin', $_POST['XML']);
	
	libxml_use_internal_errors(true);
	$xml_parse_error = false;
	
	try{

		$XMLObject = new SimpleXMLElement($response[0]);

	}
	catch(Exception $e){

		$error_msg = 'Unable to parse XML: '.$e->GetMessage();
		$xml_parse_error = true;

	}

	if ($xml_parse_error){

		echo "<pre>".$error_msg."</pre>";

	}else{
	
		echo xml_highlight($response[0]);

		if ($XMLObject->state_url){
			echo '<p><a href="'.(string)$XMLObject->state_url.'">GET Assessment State</a></p>';
		}

	}

	echo "<pre>";
	print_r($response[1]);
	echo "</pre>";

?>
</body>
</html>